package com.srpingde.hhh;

import java.io.File;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.nrs.utils.tools.CrashHandler;
import com.springde.hhh.R;
import com.srpingde.hhh.application.HhhApp;
import com.srpingde.hhh.http.AsyncHttpResponseHandler;
import com.srpingde.hhh.jiekou.HHHIml;
import com.srpingde.hhh.jiekou.HHHInterface;

import de.mindpipe.android.logging.log4j.LogConfigurator;

public class HHHianDiActivity extends Activity {
	HHHIml weiQuIml;
	Intent in ;
	//TextView gonggao_tv,jishu_tv,wenxue_tv;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_wei_qu_tian_di);
		CrashHandler crashHandler = CrashHandler.getInstance() ;
		crashHandler.init(this);
		init();
		//getDaTa();
		getData("1");
		getData("2");
		getData("3");
	}

	private void init() {
		weiQuIml = new HHHIml();
		/*gonggao_tv = (TextView) findViewById(R.id.gonggao_tv);
		jishu_tv = (TextView) findViewById(R.id.jishu_tv);
		wenxue_tv = (TextView) findViewById(R.id.wenxue_tv);*/
		//layout();
	}
	 private void getData(final String cid){
	    	String url = HHHInterface.httpHeader + "api.php?tab=seacharticle&act=data&pagesize=100&page=1&cid="+cid;
	    	HHHIml weiQuIml = new HHHIml();
	    	weiQuIml.weiQuTianDiListHttp(HHHianDiActivity.this, url, new AsyncHttpResponseHandler() {
						@Override
						public void onSuccess(String content) {
							super.onSuccess(content);
							Log.e("mytag","得到的数据"+content);
							if(cid.equals("1")){
								//gonggao_tv.setText(WeiQuDataManage.getInstance().getMeiWenBean().getRows().get(0).getTitle());
							}else if(cid.equals("2")){
								//jishu_tv.setText(WeiQuDataManage.getInstance().getMeiWenBean().getRows().get(0).getTitle());
							}else if(cid.equals("3")){
								//wenxue_tv.setText(WeiQuDataManage.getInstance().getMeiWenBean().getRows().get(0).getTitle());
							}
						}
					});
	    	
	    }
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.youxi:
			in = new Intent(HHHianDiActivity.this,HHHFenLeiActivity.class);
			in.putExtra("id", "1");
			break;
		case R.id.jishu:
			in = new Intent(HHHianDiActivity.this,HHHFenLeiActivity.class);
			in.putExtra("id", "2");
			break;
		case R.id.wenxue:
			in = new Intent(HHHianDiActivity.this,HHHFenLeiActivity.class);
			in.putExtra("id", "3");
			break;
		case R.id.meitu:
			in = new Intent(HHHianDiActivity.this,HHHMeiTuActivity.class);
			in.putExtra("id", "4");///////////////////////////
			break;
		}
		startActivity(in);
	}

/*	// 获取数据
	private void getDaTa() {
		weiQuIml.weiQuTianDi(WeiQuTianDiActivity.this,
				new AsyncHttpResponseHandler() {
					@Override
					public void onSuccess(String content) {
						super.onSuccess(content);
						Log.e("mytag", content + "================");
					}
				});
	}*/

	private void layout() {
		// 头的高度
		TextView top_title_tv = (TextView) findViewById(R.id.top_title);
		RelativeLayout.LayoutParams titleLayoutParams = (android.widget.RelativeLayout.LayoutParams) top_title_tv.getLayoutParams();
		titleLayoutParams.height = HhhApp.getInstance().title_h();
		top_title_tv.setLayoutParams(titleLayoutParams);
		itemLyout((Button) findViewById(R.id.meitu));
		itemLyout((Button) findViewById(R.id.wenxue));
		itemLyout((Button) findViewById(R.id.jishu));
		itemLyout((Button) findViewById(R.id.youxi));
		
	}
	private void itemLyout(Button button){
		RelativeLayout.LayoutParams layoutParams = (android.widget.RelativeLayout.LayoutParams) button.getLayoutParams();
		layoutParams.width = (int) (HhhApp.getInstance().getDisplayHightAndWightPx()[1]/2);
		layoutParams.height = (int) (HhhApp.getInstance().getDisplayHightAndWightPx()[1]/2);
		button.setLayoutParams(layoutParams);
	}
}